package cn.iocoder.yudao.module.strategy.dal.mysql.strategy;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.strategy.dal.dataobject.strategy.StrategyDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.strategy.controller.admin.strategy.vo.*;

/**
 * 企业战略（短期、长期） Mapper
 *
 * @author huangjunwei
 */
@Mapper
public interface StrategyMapper extends BaseMapperX<StrategyDO> {

    default PageResult<StrategyDO> selectPage(StrategyPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StrategyDO>()
                .eqIfPresent(StrategyDO::getId, reqVO.getId())
                .eqIfPresent(StrategyDO::getOrganizationId, reqVO.getOrganizationId())
                .likeIfPresent(StrategyDO::getStrategyName, reqVO.getStrategyName())
                .likeIfPresent(StrategyDO::getStrategyTarget, reqVO.getStrategyTarget())
                .likeIfPresent(StrategyDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(StrategyDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(StrategyDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(StrategyDO::getDecisionUser, reqVO.getDecisionUser())
                .likeIfPresent(StrategyDO::getRemark, reqVO.getRemark())
                .eqIfPresent(StrategyDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(StrategyDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(StrategyDO::getUpdater, reqVO.getUpdater())
                .betweenIfPresent(StrategyDO::getUpdateTime, reqVO.getUpdateTime())
                .eqIfPresent(StrategyDO::getDeleted, reqVO.getDeleted())
                .eqIfPresent(StrategyDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(StrategyDO::getId));
    }

    default List<StrategyDO> selectList(StrategyExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<StrategyDO>()
                .eqIfPresent(StrategyDO::getId, reqVO.getId())
                .eqIfPresent(StrategyDO::getOrganizationId, reqVO.getOrganizationId())
                .likeIfPresent(StrategyDO::getStrategyName, reqVO.getStrategyName())
                .likeIfPresent(StrategyDO::getStrategyTarget, reqVO.getStrategyTarget())
                .likeIfPresent(StrategyDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(StrategyDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(StrategyDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(StrategyDO::getDecisionUser, reqVO.getDecisionUser())
                .likeIfPresent(StrategyDO::getRemark, reqVO.getRemark())
                .eqIfPresent(StrategyDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(StrategyDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(StrategyDO::getUpdater, reqVO.getUpdater())
                .betweenIfPresent(StrategyDO::getUpdateTime, reqVO.getUpdateTime())
                .eqIfPresent(StrategyDO::getDeleted, reqVO.getDeleted())
                .eqIfPresent(StrategyDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(StrategyDO::getId));
    }

}
